When the last arguments to a function are closures, it’s possible and often desirable to write these closures after the function’s parentheses.
These are called trailing closure arguments. In order to help distinguish trailing closure arguments from independent code blocks, it is best
to begin the first closure argument on the same line as the function call and each following closure argument on the last line of the preceding
one.
Noncompliant code example
funWithClosureArgument()
{ // Noncompliant; looks like an independent code block
print("Hello world")
}
funWith3ClosureArguments {
print("Hello world")
} b:
{ // Noncompliant; looks like an independent code block
print("Hello world")
}
c: { // Noncompliant; looks like an independent code block
print("Hello world")
}
Compliant solution
funWithClosureArgument() {
print("Hello world")
}
funWith3ClosureArguments {
print("Hello world")
} b: {
print("Hello world")
} c: {
print("Hello world")
}